package com.hdaccp.shuiguoD.controller;

import com.hdaccp.shuiguoD.entity.Huiyuan;
import com.hdaccp.shuiguoD.entity.Huiyuanjibie;
import com.hdaccp.shuiguoD.entity.Shangpin;
import com.hdaccp.shuiguoD.service.HuiyuanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/huiyuan")
@Scope("prototype")
public class HuiyuanController {
    @Autowired
    private HuiyuanService huiyuanService;

    public static int a;

    @RequestMapping("/query")
    @ResponseBody
    public Map<String,Object> query(int offset, int limit){
       /* Map<String,Object> map = new HashMap<>() ;
        map.put("rows",userInfoService.findAll(offset,limit)) ;
        map.put("total",userInfoService.findTotalCount()) ;
        return  map ;*/

        return  null ;
    }



    @RequestMapping("/querySearch")
    @ResponseBody
    public Map<String,Object> querySearch(String hname, int offset, int limit){
        Map<String,Object> map = new HashMap<String,Object>() ;
        map.put("rows",huiyuanService.findAll(hname,offset,limit)) ;
        map.put("total",huiyuanService.findTotalCount(hname)) ;
        return  map ;
    }

//    @RequestMapping("/Search")
//    @ResponseBody
//    public Map<String,Object> Search(String hname,int offset, int limit){
//        Map<String,Object> map = new HashMap<String,Object>() ;
//        map.put("rows",huiyuanService.user(hname,offset,limit)) ;
//        map.put("total",huiyuanService.findTotalCount(hname)) ;
//        return  map ;
//    }
@RequestMapping("/getAll")
@ResponseBody
public List<Huiyuan> getAll() {
    return huiyuanService.getAll() ;
}

    @RequestMapping("/getvip")
    @ResponseBody
    public Huiyuanjibie getsid(String hname){
        System.out.println(hname);
        a=huiyuanService.query(hname);
        System.out.println(a);
        System.out.println("--------------");
        return huiyuanService.query1(a);
    }


}
